<?php
/**
 * Created by PhpStorm.
 * User: leo
 * Date: 2018/5/11
 * Time: 18:12
 */
include "../classes/logincheck.php";
include '../classes/conn.php';
if(islogin()!='teacher_login'){
    die('error');
}
$query="select num from class where num='{$_POST['update_class_num']}'";
$res=mysql_query($query);
if(mysql_num_rows($res)>=1){
    $query = "update class set name='{$_POST['update_class_name']}' where num='{$_POST['class_num']}'";
    $res = mysql_query($query);
    if ($res) {
        echo 'exist1';
    } else echo '0';
}
else {
    $query = "update class set num='{$_POST['update_class_num']}',name='{$_POST['update_class_name']}' where num='{$_POST['class_num']}'";
    $res = mysql_query($query);
    if ($res) {
        echo '1';
    } else echo '0';
}
